 //1.公用样式
 require('../../assets/css/index.js')
 //当前页面样式
 require('./DynamicList.less')

    //2.公用js
let dom=require('../../utils/dom.js');
let https=require('../../utils/https.js');
let uti=require('../../utils/utils.js');
let local=require('../../utils/local.js');

    //3.当前页面效果
// console.log(dom);
//相当于文档加载事件
dom.ready(function(){
    dom.ft('DynamicList');
    ition.addEventListener('click',function(){
        location.href='./addMotiaon.html'
    });
    let course=dom.getById('#course');
   
    
    https.get('/api/train/courseList',function(res){
        res.data.map(function(v,i){
          if(i==0){
              let appc=`
              <div data-id="${v.courseId}" class="img">
              <img src="${https.BASE_URL+v.imgurl}" alt="">
                    <div class="texts">
                        <div class="txtTop">${v.name}</div>
                        <div>${v.desc}</div>
                    </div>
                </div>
              `
              course.innerHTML=appc;
          }
        })
    })
    course.addEventListener('click',function(e){
        // console.log(e.target.parentNode);
        let id=e.target.parentNode.dataset.id;
        if(id){
          local.set('id',id);
          location.href='./courseDetails.html'
          }
      });
    
})